/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.heyma.web.clientes;

import com.icg.entityclassutils.EntityResult;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.heyma.core.service.IEntityServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 *
 * @author Ruben Q. Huanacuni Cano
 * @version 1.0
 * @since 30-julio-2013
 */

@Controller
public class ClientesController {
    
    @Autowired
    IEntityServices service;

    @RequestMapping(value = "/formcliente")
    public String formCliente() {
        return "/clientes/RegistrarCliente";
    }

    @RequestMapping(value = "/registrarCliente", method = RequestMethod.POST)
    public String registrar(HttpServletRequest request) {
        try {
            Map<String, Object> insertable = service.buildPersistenObjectFromRequest("public", "cliente", request);
            EntityResult er = service.persist(insertable, "public", "cliente");
            return "/clientes/RegistrarCliente";
        } catch (Exception e) {
        }
        return "/clientes/RegistrarCliente";
    }
    
}
